package com.bw.lib_image

import android.view.RoundedCorner
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners

/**
 * @author ytx
 * @date 2025-09-16 09:17
 * @description
 */
object ImageBindingAdapter {
    @BindingAdapter("avatarUrl")
    @JvmStatic
    fun avatarUrl(imageView:ImageView,url:String){
        GlideApp.with(imageView.context)
            .load(url)
            .transform(CircleCrop())
            .into(imageView)
    }

    @BindingAdapter("url")
    @JvmStatic
    fun url(imageView:ImageView,url:String){
        GlideApp.with(imageView.context)
            .load(url)
            .into(imageView)
    }
    @BindingAdapter("roundedUrl")
    @JvmStatic
    fun roundedUrl(imageView:ImageView,url:String){
        GlideApp.with(imageView.context)
            .load(url)
            .transform(RoundedCorners(10))
            .into(imageView)
    }
}